package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.entity.PreOutOrder;
import com.project.entity.Product;
import com.project.mapper.PreOutOrderMapper;
import com.project.mapper.ProductMapper;
import com.project.service.PreOutOrderService;
import com.project.service.ProductService;
import org.springframework.stereotype.Service;

/**
 * 商品业务接口实现类
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
    @Override
    public IPage<Product> cutByItem(Integer pageNum, String productName, String type) {
        QueryWrapper<Product> qw = new QueryWrapper<>();
        if (productName != null && productName != ""){
            qw.like("p_name",productName);
        }
        if (type != null && type != ""){
            qw.eq("p_type",type);
        }
        Page<Product> page = baseMapper.selectPage(new Page<>(pageNum,3),qw);
        return page;
    }
}
